﻿<%@ Page Language="C#" MasterPageFile="~/admin.master" AutoEventWireup="true" Inherits="MediaMonitor.Admin.Data_Mgmt_Commercial2"
    Theme="default" Title="Data Management - Commercial's Log" CodeBehind="data-mgmt-commercial2.aspx.cs" %>


<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     <script type="text/javascript">
          function DateSelected(sender, eventArgs) {
             var date = eventArgs.get_renderDay().get_date();
             var dfi = sender.DateTimeFormatInfo;
             var formattedDate = dfi.FormatDate(date, dfi.ShortDatePattern);

             var calE = $find("<%= calE.ClientID %>");

             calE.selectDate(date, true)

         }

           function conformbox() {
             var con = confirm("Are you sure to delete this record?");
             if (con == true) {
                 return true;
             }
             else {
                 return false;
             }
         }

         function conformbox2() {
             var con2 = confirm("Are you sure to delete all the dates?");
             if (con2 == true) {
                 return true;
             }
             else {
                 return false;
             }
         }
         </script>
        <script src="../rad-scripts/rad.js" type="text/javascript"></script>

    </telerik:RadCodeBlock>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server">
     <telerik:RadAjaxPanel ID="radPanel" runat="server" RestoreOriginalRenderDelegate="false">
       <table border="0" cellpadding="0" cellspacing="0" style="margin-bottom:20px;">
             <tr>
        <td colspan="2">
            <b>Dates</b><br /><br />
        </td>
    </tr>

   
    <tr>
        <td></td>
        <td>
            <table>
                <tr valign="top">
                    <td>
                        From Date
                        <br />
                        <telerik:RadCalendar AutoPostBack="false" ID="calS" runat="server" EnableMultiSelect="false"
                            ClientEvents-OnDateSelected="DateSelected">
                        </telerik:RadCalendar>
                    </td>
                    <td><div style="width:50px;"></div></td>
                    <td>
                        To Date
                        <br />
                        <telerik:RadCalendar AutoPostBack="false" ID="calE" runat="server" EnableMultiSelect="false">
                        </telerik:RadCalendar>
                    </td>
                     <td><div style="width:50px;"></div></td>
                       <td>
                      
                       <asp:LinkButton ID="btnDeleteAll" runat="server" Text=".. Delete .." OnClientClick="return conformbox();" OnClick="btnDeleteAll_Clicked" Font-Size="16" >
                        </asp:LinkButton>
                    </td>
                    
                </tr>
                
                 <tr>
    <td  colspan="2" style="padding-top:20px;">
       <asp:LinkButton ID="btnDeleteEverything" runat="server" Text=".. Delete all the dates .." OnClientClick="return conformbox2();" OnClick="btnDeleteEverything_Clicked" Font-Size="16" >
                        </asp:LinkButton>
    </td>
    </tr>
            </table>
        </td> 
    </tr>
            </table>

     <div>
         Click the <img src="../App_Themes/default/cssimg/exapand.png" style="display:inline;" /> link at the left side of records to expand the data.
     <br />
     </div>
        
            <telerik:RadGrid ID="radGrid" runat="server" AllowFilteringByColumn="false" AllowPaging="True"
                AllowSorting="True" GridLines="None" Skin="Hay" OnNeedDataSource="radGrid_NeedDataSource" 
                AutoGenerateColumns="False" PageSize="50" OnDeleteCommand="radGrid_DeleteCommand" >
               
                <MasterTableView DataKeyNames="DateInt" Width="200">
                    <Columns>
                        <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record?" ConfirmTitle="Delete Confirmation" CommandName="Delete" ItemStyle-Width="50"  />
                        <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="RFDate" HeaderText="RF Date" HtmlEncode="false"
                                    DataFormatString="{0:d}" ItemStyle-Font-Size="Larger" ItemStyle-BackColor="#575757" ItemStyle-ForeColor="White" ItemStyle-Font-Bold="true"  />
                    </Columns>
                    
                    <DetailTables>
                        <telerik:GridTableView DataSourceID="sqlDSComm" PageSize="15" AllowFilteringByColumn="true"
                            AllowSorting="true" AllowPaging="true" DataKeyNames="ID" >
                            <ParentTableRelation>
                                <telerik:GridRelationFields MasterKeyField="DateInt" DetailKeyField="DateInt" />
                            </ParentTableRelation>
                            <Columns>
                                <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record?" ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" DataField="RFDate" HeaderText="RF Date" HtmlEncode="false"
                                    DataFormatString="{0:d}" />
                             
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="Duration" HeaderText="Duration" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="Typology" HeaderText="Typology" /> 
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="RealCost" HeaderText="Real Cost" DataFormatString="{0:c2}" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="PositionInBreak" HeaderText="Pos" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="NumberOfSpotsInBreak" HeaderText="No. of Spots" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="TypeOfSpot" HeaderText="Type Spot" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="TypeOfBuyName" HeaderText="Type of Buy" UniqueName="TypeOfBuyName" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="AdvertiserName" HeaderText="Advertiser" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="AgencyName" HeaderText="Agency" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="BrandName" HeaderText="Brand" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="MediaName" HeaderText="Media" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProgramName" HeaderText="Program" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SectorName" HeaderText="Sector" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SubSectorName" HeaderText="SubSector" />
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" DataField="SubSector2Name" HeaderText="SubSector2" UniqueName="SubSector2Name" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="CategoryName" HeaderText="Category" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProductName" HeaderText="Product" />
                                <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProdVersionName" HeaderText="ProdVersion" />
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>    
                </MasterTableView>
                
                <ClientSettings>
                    <Scrolling AllowScroll="false" />
                    <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
                </ClientSettings>
                <FilterMenu OnClientShowing="MenuShowing" />
                 
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
   
    
    <asp:SqlDataSource ID="sqlDSComm" runat="server" ConnectionString="<%$ ConnectionStrings:DBAdex %>"
        SelectCommand="SELECT [ID], [MediaCode]
      ,CONVERT (datetime,convert(char(8),RFDate)) as RFDate,RFDate as DateInt
      ,[TimeStart]
      ,[TimeEnd]
      ,[Duration]
      ,[ProgramCode]
      ,[ProgramName]
      ,[Typology]
      ,[NominalCost]
      ,[RealCost]
      ,[PositionInBreak]
      ,[NumberOfSpotsInBreak]
      ,[TypeOfSpot]
      ,[TypeOfBuyCode]
      ,[TypeOfBuyName]
      ,[ProdVersionCode]
      ,[ProdVersionName]
      ,[ProductCode]
      ,[ProductName]
      ,[Constant1]
      ,[Constant2]
      ,[CategoryCode]
      ,[CategoryName]
      ,[SubSectorCode]
      ,[SubSectorName]
      ,[SectorCode]
      ,[SectorName]
      ,[Constant3]
      ,[BrandCode]
      ,[BrandName]
      ,[AdvertiserCode]
      ,[AdvertiserName]
      ,[Constant4]
      ,[AgencyCode]
      ,[AgencyName]
  FROM commercialLog1 WHERE RFDate = @DateInt">
        <SelectParameters>
            <asp:Parameter Name="DateInt" DefaultValue="0" Type="Int32" />
            
        </SelectParameters>
    </asp:SqlDataSource>
    
</asp:Content>

